<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2017 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.

OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2017 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

See doc/COPYRIGHT.rdoc for more details.

++#%>

<%= toolbar title: @version.name do %>
 <% if authorize_for(:versions, :edit) %>
    <li class="toolbar-item">
      <%= link_to(edit_version_path(@version), class: 'button') do %>
        <i class="button--icon icon-edit"></i>
        <span class="button--text"><%= l(:button_edit) %></span>
      <% end %>
    </li>
  <% end %>
  <% if authorize_for(:wiki, :edit) && !(@version.wiki_page_title.blank? || @version.project.wiki.nil?) %>
    <li class="toolbar-item">
      <%= link_to({controller: '/wiki', action: 'edit',
                   project_id: @version.project,
                   id: @version.wiki_page_title},
                   class: 'button') do %>
        <i class="button--icon icon-edit"></i>
        <span class="button--text"><%= l(:button_edit_associated_wikipage, page_title: truncate(@version.wiki_page_title, length: 50, separator: ' ')) %></span>
      <% end %>
    </li>
  <% end %>
  <%= call_hook(:view_versions_show_contextual, { version: @version, project: @project }) %>
<% end %>


<div id="version-summary">
  <% if @version.estimated_hours > 0 || User.current.allowed_to?(:view_time_entries, @project) %>
    <fieldset class="form--fieldset"><legend class="form--fieldset-legend"><%= l(:label_time_tracking) %></legend>
      <table>
        <tr>
          <td width="130px" align="right"><%= Version.human_attribute_name(:estimated_hours) %></td>
          <td width="240px" class="total-hours"width="130px" align="right"><%= html_hours(l_hours(@version.estimated_hours)) %></td>
        </tr>
        <% if User.current.allowed_to?(:view_time_entries, @project) %>
          <tr>
            <td width="130px" align="right"><%= l(:label_spent_time) %></td>
            <td width="240px" class="total-hours"><%= html_hours(l_hours(@version.spent_hours)) %></td>
          </tr>
        <% end %>
      </table>
    </fieldset>
  <% end %>

  <div id="status_by">
    <%= render_status_by(@version, params[:status_by]) if @version.fixed_issues.count > 0 %>
  </div>
</div>

<div id="roadmap">
  <%= render partial: 'versions/overview', locals: {version: @version} %>
  <%= render(partial: "wiki/content", locals: {content: @version.wiki_page.content}) if @version.wiki_page %>

  <% if @issues.present? %>
    <fieldset class="form--fieldset related_issues"><legend class="form--fieldset-legend"><%= l(:label_related_work_packages) %></legend>
      <ul>
        <% @issues.each do |issue| -%>
          <li><%= link_to_work_package(issue, project: issue.project != @version.project) %></li>
        <% end -%>
      </ul>
    </fieldset>
  <% end %>
</div>

<%= call_hook :view_versions_show_bottom, version: @version %>

<% html_title h(@version.name) %>
